package com.zzyl.mapper;

import com.zzyl.entity.Member;
import org.apache.ibatis.annotations.*;

/**
 * @author sjqn
 */
@Mapper
public interface MemberMapper {
    @Select("select * from member where open_id = #{openId}")
    Member getByOpenId(String openId);

    @Insert(" INSERT INTO member ( phone, name, avatar, open_id, gender, create_by, create_time)\n" +
            "        VALUES ( #{phone}, #{name}, #{avatar}, #{openId}, #{gender}, #{createBy}, #{createTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void save(Member member);//确实没有返回值，但是上面的注解自动把id返回回来给member对象了

    @Update("UPDATE member SET\n" +
            "                          phone = #{phone},\n" +
            "                          name = #{name},\n" +
            "                          avatar = #{avatar},\n" +
            "                          open_id = #{openId},\n" +
            "                          gender = #{gender},\n" +
            "                          update_by = #{updateBy},\n" +
            "                          update_time = #{updateTime}\n" +
            "        WHERE id = #{id}")
    void update(Member member);
}